package QueryHandler;

import java.util.Vector;

import DB.Table;

/*
 * Relation represents a real relation by name, its fields - 
 * those which have a predicate to satisfied, the predicate is also 
 * in the vector "vars" of RelationVar - and the Table it is connected to.
 */

public class Relation {

	private String name;
	private Vector<RelationVar> vars;
	private Table table;
	
/*
 * Constructor
 */
	
	public Relation(Table t, String name, Vector<RelationVar> vars) {
		this.name = name;
		this.vars = vars;
		this.table  = t;
	} 

/*
 * Return all the predicates - separate between the fields of the 
 * relation and its Predicates
 */
	
	public Vector<Predicate> findAllPreds(){
		Vector<Predicate> ans = new Vector<Predicate>(); 
		for (int i = 0; i < vars.size(); i++){
			if (!vars.elementAt(i).isVar())
				ans.add((Predicate)vars.elementAt(i));				
		}
		return ans;
	}
	
/////////////////////////////////////
//				Getters		       //
/////////////////////////////////////
	
	public Table getTable() {
		return table;
	}


	public Vector<RelationVar> getVars() {
		return vars;
	}
}
